var APP_PATH="";
function init(exists,path){
	APP_PATH = path;
	if(exists=="false"){
		var attention_li = document.getElementById("attention_li");
		attention_li.innerHTML="[用户名]或[密码]错误";
	}
	document.getElementById("userName").focus();
	changeValidator();
}
			
			function doCheck(){
				var userName=document.getElementById("userName");
				var userPassword=document.getElementById("userPassword");
				var attention_li = document.getElementById("attention_li");
				var validator = document.getElementById("validator");
				if(userName.value=="" && userPassword.value==""){
					attention_li.innerHTML="请输入[用户名]和[密码]";
					userName.focus();
					return false;
				}
				if(userName.value==""){
					attention_li.innerHTML="请输入[用户名]";
					userName.focus();
					return false;
				}
				if(userPassword.value==""){
					attention_li.innerHTML="请输入[密码]";
					userPassword.focus();
					return false;
				}
				if(validator.value==""){
					attention_li.innerHTML="请输入[验证码]";
					validator.focus();
					return false;
				}
				var validatorStr=getValidator();
				if(validatorStr != validator.value){
					attention_li.innerHTML="[验证码]不正确";
					validator.value="";
					validator.focus();
					changeValidator();
					return false;
				}
				
				return true;
			}
			function changeValidator(){
				var obj=document.getElementById("img1");
				obj.src=APP_PATH+"/noFilter/login.do?method=changeValidator&type=login&timestamp="+getUnixTime();
			}
			
			function getUnixTime()
			{  
				 var datum = new Date();
				 return datum.getTime();
			}
			
			function getValidator(){
				var param="type=login";
				var validator="";
				jQuery.ajax({
					type: "post",
					async:false,
					dataType: "Text",
					data: param,
					url: APP_PATH+"/login.do?method=getLoginValidator",
					contentType: "application/x-www-form-urlencoded; charset=gb2312",
					complete: function( res, status ) {
						var returnValue=res.responseText;
						validator = returnValue;
					}
				});
				return validator;
			}